package com.wyzz.hr.action;

import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;

import com.wyzz.hr.base.BaseAction;
import com.wyzz.hr.bo.AuthBo;
import com.wyzz.hr.bo.IClientBO;
import com.wyzz.hr.pojo.Authority;
import com.wyzz.hr.pojo.Client;
import com.wyzz.hr.spring.SpringBeanFactory;

public class AuthListAction extends BaseAction {

	public AuthListAction() {
		authList1 = new ArrayList();
		authList2 = new ArrayList();
		authList3 = new ArrayList();
		authList4 = new ArrayList();
		authList5 = new ArrayList();
		authList6 = new ArrayList();
		authList7 = new ArrayList();
		authList8 = new ArrayList();
		authList9 = new ArrayList();
	}

	public String execute() throws Exception {
		HttpSession sessionClient = ServletActionContext.getRequest()
				.getSession();
		String clientIds = sessionClient.getAttribute("clientNo").toString();
		IClientBO clientBo = (IClientBO) SpringBeanFactory.getBean("clientBo");
		Client client = clientBo.loadOneClient(clientIds);
		Hashtable clientTable = ClientLimit.getClientLimit(client);
		String authIds[] = ((String) clientTable.get("authLimit")).split(",");
		List authIdList = new ArrayList();
		String arr$[] = authIds;
		int len$ = arr$.length;
		for (int i$ = 0; i$ < len$; i$++) {
			String auth = arr$[i$];
			authIdList.add(auth);
		}

		AuthBo authBo = (AuthBo) SpringBeanFactory.getBean("authService");
		List list = authBo.getAuthList();
		for (int authIndex = 0; authIndex < list.size(); authIndex++) {
			Authority auth = (Authority) list.get(authIndex);
			if (authIdList.contains(auth.getId().toString()))
				auth.setAuthorityActionNo("yes");
			else
				auth.setAuthorityActionNo("no");
			String firstModelString = auth.getAuthorityModuleNo().substring(0,
					1);
			if ("1".equals(firstModelString)) {
				authList1.add(auth);
				continue;
			}
			if ("2".equals(firstModelString)) {
				authList2.add(auth);
				continue;
			}
			if ("3".equals(firstModelString)) {
				authList3.add(auth);
				continue;
			}
			if ("4".equals(firstModelString)) {
				authList4.add(auth);
				continue;
			}
			if ("5".equals(firstModelString)) {
				authList5.add(auth);
				continue;
			}
			if ("6".equals(firstModelString)) {
				authList6.add(auth);
				continue;
			}
			if ("7".equals(firstModelString)) {
				authList7.add(auth);
				continue;
			}
			if ("8".equals(firstModelString)) {
				authList8.add(auth);
				continue;
			}
			if ("9".equals(firstModelString))
				authList9.add(auth);
		}

		return "success";
	}

	public List getAuthList1() {
		return authList1;
	}

	public void setAuthList1(List authList1) {
		this.authList1 = authList1;
	}

	public List getAuthList2() {
		return authList2;
	}

	public void setAuthList2(List authList2) {
		this.authList2 = authList2;
	}

	public List getAuthList3() {
		return authList3;
	}

	public void setAuthList3(List authList3) {
		this.authList3 = authList3;
	}

	public List getAuthList4() {
		return authList4;
	}

	public void setAuthList4(List authList4) {
		this.authList4 = authList4;
	}

	public List getAuthList5() {
		return authList5;
	}

	public void setAuthList5(List authList5) {
		this.authList5 = authList5;
	}

	public List getAuthList6() {
		return authList6;
	}

	public void setAuthList6(List authList6) {
		this.authList6 = authList6;
	}

	public List getAuthList7() {
		return authList7;
	}

	public void setAuthList7(List authList7) {
		this.authList7 = authList7;
	}

	public List getAuthList8() {
		return authList8;
	}

	public void setAuthList8(List authList8) {
		this.authList8 = authList8;
	}

	public List getAuthList9() {
		return authList9;
	}

	public void setAuthList9(List authList9) {
		this.authList9 = authList9;
	}

	private static final long serialVersionUID = 1L;
	private List authList1;
	private List authList2;
	private List authList3;
	private List authList4;
	private List authList5;
	private List authList6;
	private List authList7;
	private List authList8;
	private List authList9;
}
